package br.com.agiledev.webscrum.eao;

import java.util.List;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

import br.com.agiledev.webscrum.entity.ItemProduct;
import br.com.agiledev.webscrum.entity.Product;

@Name("productEAO")
@Scope(ScopeType.APPLICATION)
@AutoCreate
public class ProductEAO extends BaseEAO<Product>{
 
    @SuppressWarnings("unchecked")
    public List<ItemProduct> itensProductSomente(Long oid) {
	return getEntityManager().createQuery("select ip from ItemProduct ip where ip.product.id = :oid and ip.item not in (select ir.item from ItemRelease ir where ir.release.product.id = :oid) order by ip.item.prioridade desc")
		.setParameter("oid", oid)
		.getResultList();
    }
    
}
